<?php
function Spider_360buy_Get_YinYue_List($sqlfile,$url,$localCateogryId){
	$s=snoopy_fetch($url);
	$p='#<div class="m" id="plist">(.*)<div class="m clearfix">#isU';
	preg_match_all($p,$s,$d);
	$listhtml=$d[1][0];

	$pTitle='#<dt class="p-name"><a target=\'_blank\' href="http://mvd.360buy.com/(.*)\.html">(.*)</a></dt>#isU';
	preg_match_all($pTitle,$listhtml,$d);

	$pTitle="#<img onerror=\"this.src='http://www.360buy.com/images/none/none_150.gif'\" src=\"http://(.*)\" width=\"130\" height=\"130\" />#isU";
	preg_match_all($pTitle,$listhtml,$Cover);


	$pH1='#<h1>(.*)</h1>#isU';
	preg_match_all($pH1,$s,$dH1);
	
	foreach($d[1] as $k=>$v){
		$data=array();
		$data['title']=$d[2][$k];
		$data['buy360BookId']=$v;
		$data['h1cate']=$dH1[1][0];
		$data['fromurl']=$url;
		$data['coverurl']='http://'.$Cover[1][$k];
		$data['localCateogryId']=$localCateogryId;
		$query=makeInsertSQL('buy360_yinyue_product',$data);
		file_put_contents($sqlfile,$query.PHP_EOL,8);
	}
}



function Spider_360buy_Get_YingShi_List($sqlfile,$url,$localCateogryId){
	$s=snoopy_fetch($url);
	$p='#<div class="m" id="plist">(.*)<div class="m clearfix">#isU';
	preg_match_all($p,$s,$d);
	$listhtml=$d[1][0];

	$pTitle='#<dt class="p-name"><a target=\'_blank\' href="http://mvd.360buy.com/(.*)\.html">(.*)</a></dt>#isU';
	preg_match_all($pTitle,$listhtml,$d);

	$pTitle="#<img onerror=\"this.src='http://www.360buy.com/images/none/none_150.gif'\" src=\"http://(.*)\" width=\"130\" height=\"130\" />#isU";
	preg_match_all($pTitle,$listhtml,$Cover);


	$pH1='#<h1>(.*)</h1>#isU';
	preg_match_all($pH1,$s,$dH1);
	
	foreach($d[1] as $k=>$v){
		$data=array();
		$data['title']=$d[2][$k];
		$data['buy360BookId']=$v;
		$data['h1cate']=$dH1[1][0];
		$data['fromurl']=$url;
		$data['coverurl']='http://'.$Cover[1][$k];
		$data['localCateogryId']=$localCateogryId;
		$query=makeInsertSQL('buy360_yingshi_product',$data);
		file_put_contents($sqlfile,$query.PHP_EOL,8);
	}
}

function Spider_360buy_Get_Book_CoverDir($coverdir,$BookId){
	$file=$coverdir.'/'.substr(md5($BookId),0,2).'/'.substr(md5($BookId),4,2).'/'.$BookId.'.jpg';
	return $file;
}


function Spider_360buy_Get_eBook_Content($sqlfile,$url,$buy360eBookId){
	$s=snoopy_fetch($url);
	$pTitle='#<title>(.*)</title>#isU';
	preg_match_all($pTitle,$s,$arrTitle);

	$data['fromurl']=$url;

	$pSrcJpg='#src=\'(.*)\.jpg\'#isU';

	$data['buy360eBookId']=$buy360eBookId;

	#提取标题
	$data['title']=$arrTitle[1][0];
	$data['title']=str_replace('- 京东图书','',$data['title']);
	$data['title']=str_replace(iconv("UTF-8", "GB2312//IGNORE",'- 京东图书'),'',$data['title']);
	$data['title']=str_replace('【摘要 书评 试读】','',$data['title']);
	$data['title']=str_replace(iconv("UTF-8", "GB2312//IGNORE",'【摘要 书评 试读】'),'',$data['title']);
	$data['title']=str_replace(' – 京东商城电子书频道','',$data['title']);
	$data['title']=str_replace(iconv("UTF-8", "GB2312//IGNORE",'– 京东商城电子书频道'),'',$data['title']);
	$data['title']=str_replace('电子书下载、在线阅读、内容简介、评论','',$data['title']);
	$data['title']=str_replace(iconv("UTF-8", "GB2312//IGNORE",'电子书下载、在线阅读、内容简介、评论'),'',$data['title']);
	$data['title']=str_replace(iconv("UTF-8", "GBK//IGNORE",'–'),'',$data['title']);
	$data['title']=str_replace('–','',$data['title']);

	$pH1Title='#var title = "(.*)";#isU';
	preg_match_all($pH1Title,$s,$arrH1Title);
	$data['h1title']=strip_tags($arrH1Title[1][0]);

	$pBigPic='#var img = "(.*)";#isU';
	preg_match_all($pBigPic,$s,$arrBigPic);
	$data['BigPic']=$arrBigPic[1][0];

	#提取简介
	$pNeiRongJianJie='#<h3>'.iconv("UTF-8", "GB2312//IGNORE",'内容简介').'</h3>(.*)<div class="more">#isU';
	preg_match_all($pNeiRongJianJie,$s,$arrNeiRongJianJie);
	$data['NeiRongJianJie']=strip_tags($arrNeiRongJianJie[1][0],'<p> <br>');

	$pZuoZheJianJie='#<h3>'.iconv("UTF-8", "GB2312//IGNORE",'作者简介').'</h3>(.*)<div class="more">#isU';
	preg_match_all($pZuoZheJianJie,$s,$arrZuoZheJianJie);
	$data['ZuoZheJianJie']=strip_tags($arrZuoZheJianJie[1][0],'<p> <br>');

	$pMuLu='#<h3>'.iconv("UTF-8", "GB2312//IGNORE",'目录').'</h3>(.*)<div class="more">#isU';
	preg_match_all($pMuLu,$s,$arrMuLu);
	$data['MuLu']=strip_tags($arrMuLu[1][0],'<p> <br>');

	$pBianJiTuiJian='#<h3>'.iconv("UTF-8", "GB2312//IGNORE",'编辑推荐').'</h3>(.*)<div class="more">#isU';
	preg_match_all($pBianJiTuiJian,$s,$arrBianJiTuiJian);
	$pSrcJpg='#src="(.*)\.jpg"#isU';
	preg_match_all($pSrcJpg,$arrBianJiTuiJian[1][0],$arrTuiJianJpgs);

	if($arrTuiJianJpgs[1]&&is_array($arrTuiJianJpgs[1])){
		foreach($arrChaTuJpgs[1] as $kct=>$JpgChatu){
			if($kct>5){break;}
			$data['tuijian'.$kct]=$JpgChatu.'.jpg';
		}
	}

	$data['BianJiTuiJian']=strip_tags($arrBianJiTuiJian[1][0],'<p> <br>');

	$pYinShuaShiJian='#<li><span>'.iconv("UTF-8", "GB2312//IGNORE",'出版时间：').'</span>(.*)</li>#isU';
	preg_match_all($pYinShuaShiJian,$s,$arrYinShuaShiJian);
	$data['YinShuaShiJian']=strip_tags($arrYinShuaShiJian[1][0]);

	$pChuBanShe='#<li><span>'.iconv("UTF-8", "GB2312//IGNORE",'出&nbsp;版&nbsp;社：').'</span>(.*)</li>#isU';
	preg_match_all($pChuBanShe,$s,$arrChuBanShe);
	$data['ChuBanShe']=strip_tags($arrChuBanShe[1][0]);

	$pISBN='#<div>'.iconv("UTF-8", "GB2312//IGNORE",'ＩＳＢＮ：').'(.*)</div>#isU';
	preg_match_all($pISBN,$s,$arrISBN);
	$data['ISBN']=strip_tags($arrISBN[1][0]);

	$pZiShu='#<div>'.iconv("UTF-8", "GB2312//IGNORE",'字&nbsp;&nbsp;&nbsp;&nbsp;数：').'(.*)</div>#isU';
	preg_match_all($pZiShu,$s,$arrZiShu);
	$data['ZiShu']=strip_tags($arrZiShu[1][0]);

	$pWenJianDaXiao='#<div>'.iconv("UTF-8", "GB2312//IGNORE",'文件大小：').'(.*)</div>#isU';
	preg_match_all($pWenJianDaXiao,$s,$arrWenJianDaXiao);
	$data['WenJianDaXiao']=strip_tags($arrWenJianDaXiao[1][0]);

	#提取面包屑
	$pMianBaoXie='#<div class="crumb">(.*)</div>#isU';
	preg_match_all($pMianBaoXie,$s,$arrMianBaoXie);
	$strMianBaoXie=$arrMianBaoXie[1][0];
	$pMBXLink='#"http://(.*)">(.*)</a>#isU';
	preg_match_all($pMBXLink,$strMianBaoXie,$arrCids);

	$pAuthor='#<span>'.iconv("UTF-8", "GB2312//IGNORE",'作&nbsp;&nbsp;&nbsp;&nbsp;者：').'</span>(.*)</li>#isU';
	preg_match_all($pAuthor,$s,$arrAuthor);
	$data['Author']=trim(strip_tags($arrAuthor[1][0]));
	$data['Author']=str_replace('&nbsp;'.iconv("UTF-8", "GB2312//IGNORE",'著').'&nbsp;','',$data['Author']);
	$data['Author']=preg_replace('#\s+#',' ',$data['Author']);

	foreach($arrCids[2] as $k=>$v){
		$data['cid'.strval($k+1)]=$v;
	}

	foreach($data as &$v){
		$v=trim($v);
	}unset($v);

	$query=makeInsertSQL('buy360_ebook_content',$data);
	file_put_contents($sqlfile,$query.PHP_EOL,8);

}


function Spider_360buy_Get_Book_Content($sqlfile,$url,$productId){
	$s=snoopy_fetch($url);
	$pTitle='#<title>(.*)</title>#isU';
	preg_match_all($pTitle,$s,$arrTitle);

	$data['fromurl']=$url;

	$pSrcJpg='#src=\'(.*)\.jpg\'#isU';

	#提取标题
	$data['title']=$arrTitle[1][0];
	$data['title']=str_replace('- 京东图书','',$data['title']);
	$data['title']=str_replace(iconv("UTF-8", "GB2312//IGNORE",'- 京东图书'),'',$data['title']);
	$data['title']=str_replace('【摘要 书评 试读】','',$data['title']);
	$data['title']=str_replace(iconv("UTF-8", "GB2312//IGNORE",'【摘要 书评 试读】'),'',$data['title']);
	$data['title']=str_replace('京东图书','',$data['title']);
	$data['title']=str_replace(iconv("UTF-8", "GB2312//IGNORE",'京东图书'),'',$data['title']);

	#提取面包屑
	$pMianBaoXie='#<div class="breadcrumb">(.*)<div id="hotkeywords">#isU';
	preg_match_all($pMianBaoXie,$s,$arrMianBaoXie);
	$strMianBaoXie=$arrMianBaoXie[1][0];
	$pMBXLink='#"http://(.*)">(.*)</a>#isU';
	preg_match_all($pMBXLink,$strMianBaoXie,$arrCids);

	foreach($arrCids[2] as $k=>$v){
		$data['cid'.strval($k+1)]=$v;
	}

	#提取H1Title
	$pH1Title='#<h1>(.*)</h1>#isU';
	preg_match_all($pH1Title,$s,$arrH1Title);
	$data['h1title']=strip_tags($arrH1Title[1][0]);


	#提取属性
	$pSummary='#<ul id="summary"(.*)<!--summary end-->#isU';
	preg_match_all($pSummary,$s,$arrSummary);
	$strSummary=$arrSummary[1][0];

	$pYinShuaShiJian='#<div >'.iconv("UTF-8", "GB2312//IGNORE",'印刷时间：').'(.*)</div>#isU';
	preg_match_all($pYinShuaShiJian,$strSummary,$arrYinShuaShiJian);
	$data['YinShuaShiJian']=strip_tags($arrYinShuaShiJian[1][0]);

	$pISBN='#<li ><span>'.iconv("UTF-8", "GB2312//IGNORE",'ＩＳＢＮ：').'</span>(.*)</li>#isU';
	preg_match_all($pISBN,$strSummary,$arrISBN);
	$data['ISBN']=strip_tags($arrISBN[1][0]);

	$pZhuangZhen='#<li ><span>'.iconv("UTF-8", "GB2312//IGNORE",'装　　帧：').'</span>(.*)</li>#isU';
	preg_match_all($pZhuangZhen,$strSummary,$arrZhuangZhen);
	$data['ZhuangZhen']=strip_tags($arrZhuangZhen[1][0]);

	$pYeShu='#<li ><span>'.iconv("UTF-8", "GB2312//IGNORE",'页　　数：').'</span>(.*)</li>#isU';
	preg_match_all($pYeShu,$strSummary,$arrYeShu);
	$data['YeShu']=strip_tags($arrYeShu[1][0]);

	$pKaiBen='#<li ><span>'.iconv("UTF-8", "GB2312//IGNORE",'开　　本：').'</span>(.*)</li>#isU';
	preg_match_all($pKaiBen,$strSummary,$arrKaiBen);
	$data['KaiBen']=strip_tags($arrKaiBen[1][0]);

	$pChuBanShe='#<li ><span>'.iconv("UTF-8", "GB2312//IGNORE",'出 版').'(.*)</li>#isU';
	preg_match_all($pChuBanShe,$strSummary,$arrChuBanShe);
	$data['ChuBanShe']=str_replace(iconv("UTF-8", "GB2312//IGNORE",'社： '),'',strip_tags($arrChuBanShe[1][0]));

	$pDingJia='#<li>'.iconv("UTF-8", "GB2312//IGNORE",'定&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;价：').'<del>'.iconv("UTF-8", "GB2312//IGNORE",'￥').'(.*)</del></li>#isU';
	preg_match_all($pDingJia,$s,$arrDingJia);
	$data['DingJia']=strip_tags($arrDingJia[1][0]);

	$pAuthor='#<span>'.iconv("UTF-8", "GB2312//IGNORE",'作　　者：').'</span>(.*)</li>#isU';
	preg_match_all($pAuthor,$strSummary,$arrAuthor);
	$data['Author']=trim(strip_tags($arrAuthor[1][0]));


	#提取简介
	$pNeiRongJianJie='#<h2>'.iconv("UTF-8", "GB2312//IGNORE",'内容简介 ').'</h2>(.*)<div class="more">#isU';
	preg_match_all($pNeiRongJianJie,$s,$arrNeiRongJianJie);
	$data['NeiRongJianJie']=strip_tags($arrNeiRongJianJie[1][0],'<p> <br>');

	if(!$data['NeiRongJianJie']){
	$pNeiRongJianJie='#<h2>'.iconv("UTF-8", "GB2312//IGNORE",'内容简介 <span>Book Description</span> ').'</h2>(.*)<div class="more">#isU';
	preg_match_all($pNeiRongJianJie,$s,$arrNeiRongJianJie);
	$data['NeiRongJianJie']=strip_tags($arrNeiRongJianJie[1][0],'<p> <br>');
	}

	$pMuLu='#<h2>'.iconv("UTF-8", "GB2312//IGNORE",'目录 ').'</h2>(.*)<div class="more">#isU';
	preg_match_all($pMuLu,$s,$arrMuLu);
	$data['MuLu']=strip_tags($arrMuLu[1][0],'<p> <br>');

	$pJingCaiShuZhai='#<h2>'.iconv("UTF-8", "GB2312//IGNORE",'精彩书摘 ').'</h2>(.*)<div class="more">#isU';
	preg_match_all($pJingCaiShuZhai,$s,$arrJingCaiShuZhai);
	$data['JingCaiShuZhai']=strip_tags($arrJingCaiShuZhai[1][0],'<p> <br>');

	$pChaTu='#<div class="mt"><h2>'.iconv("UTF-8", "GB2312//IGNORE",'插图').'</h2></div>(.*)</div>#isU';
	preg_match_all($pChaTu,$s,$arrChaTu);

	preg_match_all($pSrcJpg,$arrChaTu[1][0],$arrChaTuJpgs);

	if($arrChaTuJpgs[1]&&is_array($arrChaTuJpgs[1])){
		foreach($arrChaTuJpgs[1] as $kct=>$JpgChatu){
			if($kct>5){break;}
			$data['chatu'.$kct]=$JpgChatu.'.jpg';
		}
	}


	$pMeiTiPingLun='#<h2>'.iconv("UTF-8", "GB2312//IGNORE",'媒体评论 ').'</h2>(.*)<div class="more">#isU';
	preg_match_all($pMeiTiPingLun,$s,$arrMeiTiPingLun);
	$data['MeiTiPingLun']=strip_tags($arrMeiTiPingLun[1][0],'<p> <br>');

	if(!$data['MeiTiPingLun']){
	$pMeiTiPingLun='#<h2>'.iconv("UTF-8", "GB2312//IGNORE",'媒体评论  <span>Book Reviews</span>').'</h2>(.*)<div class="more">#isU';
	preg_match_all($pMeiTiPingLun,$s,$arrMeiTiPingLun);
	$data['MeiTiPingLun']=strip_tags($arrMeiTiPingLun[1][0],'<p> <br>');
	}

	$pZuoZheJianJie='#<h2>'.iconv("UTF-8", "GB2312//IGNORE",'作者简介 ').'</h2>(.*)<div class="more">#isU';
	preg_match_all($pZuoZheJianJie,$s,$arrZuoZheJianJie);
	$data['ZuoZheJianJie']=strip_tags($arrZuoZheJianJie[1][0],'<p> <br>');
	if(!$data['ZuoZheJianJie']){
	$pZuoZheJianJie='#<h2>'.iconv("UTF-8", "GB2312//IGNORE",'作者简介  <span>About the Author</span>').'</h2>(.*)<div class="more">#isU';
	preg_match_all($pZuoZheJianJie,$s,$arrZuoZheJianJie);
	$data['ZuoZheJianJie']=strip_tags($arrZuoZheJianJie[1][0],'<p> <br>');
	}

	$pQianYan='#<h2>'.iconv("UTF-8", "GB2312//IGNORE",'前言').'</h2>(.*)<div class="more">#isU';
	preg_match_all($pQianYan,$s,$arrQianYan);
	$data['QianYan']=strip_tags($arrQianYan[1][0],'<p> <br>');

	$pBianJiTuiJian='#<h2>'.iconv("UTF-8", "GB2312//IGNORE",'编辑推荐 ').'</h2>(.*)<div class="more">#isU';
	preg_match_all($pBianJiTuiJian,$s,$arrBianJiTuiJian);
	$pSrcJpg='#src="(.*)\.jpg"#isU';
	preg_match_all($pSrcJpg,$arrBianJiTuiJian[1][0],$arrTuiJianJpgs);

	if($arrTuiJianJpgs[1]&&is_array($arrTuiJianJpgs[1])){
		foreach($arrChaTuJpgs[1] as $kct=>$JpgChatu){
			if($kct>5){break;}
			$data['tuijian'.$kct]=$JpgChatu.'.jpg';
		}
	}

	$data['BianJiTuiJian']=strip_tags($arrBianJiTuiJian[1][0],'<p> <br>');


	$pBigPic='#var img = "(.*)";#isU';
	preg_match_all($pBigPic,$s,$arrBigPic);
	$data['BigPic']=$arrBigPic[1][0];

	foreach($data as &$v){
		$v=trim($v);
	}unset($v);

	$query=makeInsertSQL('buy360_book_content',$data);
	file_put_contents($sqlfile,$query.PHP_EOL,8);


}






function Spider_360buy_Get_YingShi_Content($sqlfile,$url,$productId){
	$s=snoopy_fetch($url);
	$pTitle='#<title>(.*)</title>#isU';
	preg_match_all($pTitle,$s,$arrTitle);

	$data['fromurl']=$url;

	$pSrcJpg='#src=\'(.*)\.jpg\'#isU';

	#提取标题
	$data['title']=$arrTitle[1][0];
	$data['title']=str_replace('- 京东图书','',$data['title']);
	$data['title']=str_replace(iconv("UTF-8", "GB2312//IGNORE",'- 京东图书'),'',$data['title']);
	$data['title']=str_replace('【摘要 书评 试读】','',$data['title']);
	$data['title']=str_replace(iconv("UTF-8", "GB2312//IGNORE",'【摘要 书评 试读】'),'',$data['title']);
	$data['title']=str_replace('京东图书','',$data['title']);
	$data['title']=str_replace(iconv("UTF-8", "GB2312//IGNORE",'京东图书'),'',$data['title']);

	#提取面包屑
	$pMianBaoXie='#<div class="breadcrumb">(.*)<div id="hotkeywords">#isU';
	preg_match_all($pMianBaoXie,$s,$arrMianBaoXie);
	$strMianBaoXie=$arrMianBaoXie[1][0];
	$pMBXLink='#"http://(.*)">(.*)</a>#isU';
	preg_match_all($pMBXLink,$strMianBaoXie,$arrCids);

	foreach($arrCids[2] as $k=>$v){
		$data['cid'.strval($k+1)]=$v;
	}

	#提取H1Title
	$pH1Title='#<h1>(.*)</h1>#isU';
	preg_match_all($pH1Title,$s,$arrH1Title);
	$data['h1title']=strip_tags($arrH1Title[1][0]);


	#提取属性
	$pSummary='#<ul id="summary"(.*)<!--summary end-->#isU';
	preg_match_all($pSummary,$s,$arrSummary);
	$strSummary=$arrSummary[1][0];

	$pYinShuaShiJian='#<div >'.iconv("UTF-8", "GB2312//IGNORE",'印刷时间：').'(.*)</div>#isU';
	preg_match_all($pYinShuaShiJian,$strSummary,$arrYinShuaShiJian);
	$data['YinShuaShiJian']=strip_tags($arrYinShuaShiJian[1][0]);

	$pISBN='#<li ><span>'.iconv("UTF-8", "GB2312//IGNORE",'ＩＳＢＮ：').'</span>(.*)</li>#isU';
	preg_match_all($pISBN,$strSummary,$arrISBN);
	$data['ISBN']=strip_tags($arrISBN[1][0]);

	$pZhuangZhen='#<li ><span>'.iconv("UTF-8", "GB2312//IGNORE",'装　　帧：').'</span>(.*)</li>#isU';
	preg_match_all($pZhuangZhen,$strSummary,$arrZhuangZhen);
	$data['ZhuangZhen']=strip_tags($arrZhuangZhen[1][0]);

	$pYeShu='#<li ><span>'.iconv("UTF-8", "GB2312//IGNORE",'页　　数：').'</span>(.*)</li>#isU';
	preg_match_all($pYeShu,$strSummary,$arrYeShu);
	$data['YeShu']=strip_tags($arrYeShu[1][0]);

	$pKaiBen='#<li ><span>'.iconv("UTF-8", "GB2312//IGNORE",'开　　本：').'</span>(.*)</li>#isU';
	preg_match_all($pKaiBen,$strSummary,$arrKaiBen);
	$data['KaiBen']=strip_tags($arrKaiBen[1][0]);

	$pChuBanShe='#<li ><span>'.iconv("UTF-8", "GB2312//IGNORE",'出 版').'(.*)</li>#isU';
	preg_match_all($pChuBanShe,$strSummary,$arrChuBanShe);
	$data['ChuBanShe']=str_replace(iconv("UTF-8", "GB2312//IGNORE",'社： '),'',strip_tags($arrChuBanShe[1][0]));

	$pDingJia='#<li>'.iconv("UTF-8", "GB2312//IGNORE",'定&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;价：').'<del>'.iconv("UTF-8", "GB2312//IGNORE",'￥').'(.*)</del></li>#isU';
	preg_match_all($pDingJia,$s,$arrDingJia);
	$data['DingJia']=strip_tags($arrDingJia[1][0]);

	$pAuthor='#<span>'.iconv("UTF-8", "GB2312//IGNORE",'作　　者：').'</span>(.*)</li>#isU';
	preg_match_all($pAuthor,$strSummary,$arrAuthor);
	$data['Author']=trim(strip_tags($arrAuthor[1][0]));


	#提取简介
	$pNeiRongJianJie='#<h2>'.iconv("UTF-8", "GB2312//IGNORE",'内容简介 ').'</h2>(.*)<div class="more">#isU';
	preg_match_all($pNeiRongJianJie,$s,$arrNeiRongJianJie);
	$data['NeiRongJianJie']=strip_tags($arrNeiRongJianJie[1][0],'<p> <br>');

	if(!$data['NeiRongJianJie']){
	$pNeiRongJianJie='#<h2>'.iconv("UTF-8", "GB2312//IGNORE",'内容简介 <span>Book Description</span> ').'</h2>(.*)<div class="more">#isU';
	preg_match_all($pNeiRongJianJie,$s,$arrNeiRongJianJie);
	$data['NeiRongJianJie']=strip_tags($arrNeiRongJianJie[1][0],'<p> <br>');
	}

	$pMuLu='#<h2>'.iconv("UTF-8", "GB2312//IGNORE",'目录 ').'</h2>(.*)<div class="more">#isU';
	preg_match_all($pMuLu,$s,$arrMuLu);
	$data['MuLu']=strip_tags($arrMuLu[1][0],'<p> <br>');

	$pJingCaiShuZhai='#<h2>'.iconv("UTF-8", "GB2312//IGNORE",'精彩书摘 ').'</h2>(.*)<div class="more">#isU';
	preg_match_all($pJingCaiShuZhai,$s,$arrJingCaiShuZhai);
	$data['JingCaiShuZhai']=strip_tags($arrJingCaiShuZhai[1][0],'<p> <br>');

	$pChaTu='#<div class="mt"><h2>'.iconv("UTF-8", "GB2312//IGNORE",'插图').'</h2></div>(.*)</div>#isU';
	preg_match_all($pChaTu,$s,$arrChaTu);

	preg_match_all($pSrcJpg,$arrChaTu[1][0],$arrChaTuJpgs);

	if($arrChaTuJpgs[1]&&is_array($arrChaTuJpgs[1])){
		foreach($arrChaTuJpgs[1] as $kct=>$JpgChatu){
			if($kct>5){break;}
			$data['chatu'.$kct]=$JpgChatu.'.jpg';
		}
	}


	$pMeiTiPingLun='#<h2>'.iconv("UTF-8", "GB2312//IGNORE",'媒体评论 ').'</h2>(.*)<div class="more">#isU';
	preg_match_all($pMeiTiPingLun,$s,$arrMeiTiPingLun);
	$data['MeiTiPingLun']=strip_tags($arrMeiTiPingLun[1][0],'<p> <br>');

	if(!$data['MeiTiPingLun']){
	$pMeiTiPingLun='#<h2>'.iconv("UTF-8", "GB2312//IGNORE",'媒体评论  <span>Book Reviews</span>').'</h2>(.*)<div class="more">#isU';
	preg_match_all($pMeiTiPingLun,$s,$arrMeiTiPingLun);
	$data['MeiTiPingLun']=strip_tags($arrMeiTiPingLun[1][0],'<p> <br>');
	}

	$pZuoZheJianJie='#<h2>'.iconv("UTF-8", "GB2312//IGNORE",'作者简介 ').'</h2>(.*)<div class="more">#isU';
	preg_match_all($pZuoZheJianJie,$s,$arrZuoZheJianJie);
	$data['ZuoZheJianJie']=strip_tags($arrZuoZheJianJie[1][0],'<p> <br>');
	if(!$data['ZuoZheJianJie']){
	$pZuoZheJianJie='#<h2>'.iconv("UTF-8", "GB2312//IGNORE",'作者简介  <span>About the Author</span>').'</h2>(.*)<div class="more">#isU';
	preg_match_all($pZuoZheJianJie,$s,$arrZuoZheJianJie);
	$data['ZuoZheJianJie']=strip_tags($arrZuoZheJianJie[1][0],'<p> <br>');
	}

	$pQianYan='#<h2>'.iconv("UTF-8", "GB2312//IGNORE",'前言').'</h2>(.*)<div class="more">#isU';
	preg_match_all($pQianYan,$s,$arrQianYan);
	$data['QianYan']=strip_tags($arrQianYan[1][0],'<p> <br>');

	$pBianJiTuiJian='#<h2>'.iconv("UTF-8", "GB2312//IGNORE",'编辑推荐 ').'</h2>(.*)<div class="more">#isU';
	preg_match_all($pBianJiTuiJian,$s,$arrBianJiTuiJian);
	$pSrcJpg='#src="(.*)\.jpg"#isU';
	preg_match_all($pSrcJpg,$arrBianJiTuiJian[1][0],$arrTuiJianJpgs);

	if($arrTuiJianJpgs[1]&&is_array($arrTuiJianJpgs[1])){
		foreach($arrChaTuJpgs[1] as $kct=>$JpgChatu){
			if($kct>5){break;}
			$data['tuijian'.$kct]=$JpgChatu.'.jpg';
		}
	}

	$data['BianJiTuiJian']=strip_tags($arrBianJiTuiJian[1][0],'<p> <br>');


	$pBigPic='#var img = "(.*)";#isU';
	preg_match_all($pBigPic,$s,$arrBigPic);
	$data['BigPic']=$arrBigPic[1][0];

	foreach($data as &$v){
		$v=trim($v);
	}unset($v);

	$query=makeInsertSQL('buy360_book_content',$data);
	file_put_contents($sqlfile,$query.PHP_EOL,8);


}
?>